
    <!DOCTYPE html>
    <html lang="zh-CN">
    <head>
      <meta charset="UTF-8">
      <meta name="viewport" content="width=device-width, initial-scale=1.0">
      <title>如何使用NIO和JUC提升性能 - 学习卡片</title>
      <style>
        body { font-family: sans-serif; background-color: #f0f8ff; color: #333; display: flex; flex-direction: column; align-items: center; padding: 50px 20px; }
        .header h1 { font-size: 32px; }
        .grid-container { display: grid; grid-template-columns: repeat(3, 1fr); gap: 28px; width: 100%; max-width: 1200px; }
        .card-container { perspective: 1200px; cursor: pointer; height: 250px; }
        .card { width: 100%; height: 100%; position: relative; transform-style: preserve-3d; transition: transform 0.7s; border-radius: 16px; box-shadow: 0 4px 16px rgba(0,0,0,0.08); }
        .card-container.flipped .card { transform: rotateY(180deg); }
        .card-face { position: absolute; width: 100%; height: 100%; backface-visibility: hidden; display: flex; flex-direction: column; box-sizing: border-box; border-radius: 16px; background-color: #fff; padding: 24px; }
        .card-back { background-color: #f0fff4; transform: rotateY(180deg); justify-content: space-between; }
        .card-category { font-size: 14px; color: #0052d9; margin-bottom: 8px; font-weight: 500; }
        .card-question { font-size: 20px; font-weight: 500; flex-grow: 1; display: flex; align-items: center; justify-content: center; text-align: center; }
        .card-answer-wrapper { flex-grow: 1; overflow-y: auto; }
        .card-answer { font-size: 15px; line-height: 1.7; }
        .card-footer { font-size: 13px; color: #8a919f; border-top: 1px solid #f0f0f0; padding-top: 16px; margin-top: 16px; }
        .card-source { font-size: 13px; color: #8a919f; border-top: 1px solid #f0f0f0; padding-top: 12px; margin-top: 12px; }
      </style>
    </head>
    <body>
      <div class="header">
        <h1>如何使用NIO和JUC提升性能 - 学习卡片</h1>
      </div>
      <div class="grid-container">
        
    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">理论</div>
          <div class="card-question">在现代高并发系统中，性能优化面临的三大核心挑战是什么？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">理论</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">性能优化面临的三大挑战是：1. I/O瓶颈，由传统阻塞I/O导致线程资源浪费；2. CPU利用率低，因上下文切换和锁竞争消耗大量CPU；3. 扩展性差，系统无法线性扩展以应对流量增长。</div>
          </div>
          <div class="card-source">来源: 一、性能优化的核心挑战</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">技术</div>
          <div class="card-question">Java NIO（非阻塞I/O）包含哪三个核心组件？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">技术</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">NIO的三个核心组件是：1. Channel（数据通道，如SocketChannel）；2. Buffer（数据缓冲区，如ByteBuffer）；3. Selector（多路复用器，用于监听多个Channel的事件）。</div>
          </div>
          <div class="card-source">来源: 2.2 NIO核心组件</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">特性</div>
          <div class="card-question">相较于传统的BIO模型，NIO模型在线程模型和可扩展性方面有哪些优势？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">特性</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">在线程模型上，NIO采用一个线程处理多个连接，而BIO是一个线程处理一个连接。因此，NIO的可扩展性非常优秀，尤其适用于高并发场景，而BIO的可扩展性较差。</div>
          </div>
          <div class="card-source">来源: 2.1 传统BIO vs NIO</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">技术</div>
          <div class="card-question">JUC（Java Util Concurrent）提供了哪些工具来释放多核CPU的潜力？请列举三类。</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">技术</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">JUC提供了三类主要工具来释放多核CPU潜力：1. 线程池优化（如FixedThreadPool）；2. 并发集合（如ConcurrentHashMap、BlockingQueue）；3. 原子变量与CAS（如AtomicInteger、LongAdder）。</div>
          </div>
          <div class="card-source">来源: 三、JUC释放多核CPU潜力</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">机制</div>
          <div class="card-question">在“NIO + JUC”实战架构中，网络I/O和业务逻辑是如何分离处理以提升性能的？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">机制</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">该架构通过NIO的Selector来监听和处理网络I/O事件（如连接和读写），然后将耗时的业务逻辑操作提交给JUC的线程池进行异步处理，从而避免I/O线程被业务逻辑阻塞。</div>
          </div>
          <div class="card-source">来源: 4.1 架构设计</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">模式</div>
          <div class="card-question">文档中介绍了哪三种Reactor模式？其中被Netty框架采用的是哪一种？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">模式</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">文档中介绍了三种Reactor模式：1. 单Reactor单线程；2. 单Reactor多线程；3. 主从Reactor多线程。Netty框架采用的是“主从Reactor多线程”模式。</div>
          </div>
          <div class="card-source">来源: 6.1 Reactor模式</div>
        </div>
      </div>
    </div>

      </div>
    </body>
    </html>
